package com.fmi.cloud.biz;

import android.app.Activity;
import android.content.Intent;
import android.webkit.JavascriptInterface;

import com.fmi.cloud.act.LoginActivity;
import com.fmi.thirdsdk.jpush.JPushUtil;

import cn.jpush.android.api.JPushInterface;


/**
 * JS工具
 * Created by zv on 2017-12-5.
 */
public class CommonJs {

    private Activity mActivity;

    public CommonJs(Activity activity) {
        this.mActivity = activity;
    }

    @JavascriptInterface
    public String getLoginInfo() {
        return CommonSp.getUserInfo();
    }

    @JavascriptInterface
    public void jumpLogin() {
        if (this.mActivity != null) {
            mActivity.startActivity(new Intent(mActivity, LoginActivity.class));
            CommonSp.setUserInfo("");
            CommonSp.setCityID("");
            CommonSp.setProvinceID("");
            CommonSp.setAgentID("");
            JPushInterface.cleanTags(mActivity, 0);
            mActivity.finish();
        }
    }

    @JavascriptInterface
    public void setData(String data) {
        CommonSp.setData(data);
    }

    @JavascriptInterface
    public String getData() {
        return CommonSp.getData();
    }

}
